package com.object;

import java.util.Scanner;

public class LoginDemo {
    public static void main(String[] args) {
        //定义一个构造函数
        Login user = new Login();
        user.setUsername("admin");
        user.setPassword("123qwe#");

        //开始登录信息
        Scanner scanner = new Scanner(System.in);

        for (int i = 0; i < 3; i++) {
            //输入用户名和密码
            System.out.println("请输入用户名");
            String name = scanner.nextLine();

            System.out.println("请输入密码");
            String pwd =  scanner.nextLine();

            if(name.equals(user.getUsername())  && pwd.equals(user.getPassword())){
                System.out.println("登录成功");
                break;
            }else{
                if(2-i<=0){
                    System.out.println("登录次数已经用完，账户被冻结");
                }else{
                    System.out.println("登录失败您还有"+(2-i)+"机会");
                }
            }
        }
    }
}
